﻿using System.Collections.Generic;
using System.Linq;

namespace NerdDinnerDataComponent
{
    public static class Mapper
    {
        public static IList<DinnerInfo> CreateFrom(IOrderedEnumerable<Dinner> qry)
        {
            return qry.Select(dinner => CreateFrom(dinner)).ToList();
        }
        public static IList<DinnerInfo> CreateFrom(IQueryable<Dinner> qry)
        {
            return qry.Select(dinner => CreateFrom(dinner)).ToList();
        }


       
        public static DinnerInfo CreateFrom(Dinner dinner)
        {

            return new DinnerInfo()
                       {
                           Address = dinner.Address,
                           ContactPhone = dinner.ContactPhone,
                           Country = dinner.Country,
                           Description = dinner.Description,
                           DinnerId = dinner.DinnerID,
                           EventDate = dinner.EventDate,
                           HostedBy = dinner.HostedBy,
                           Latitude = dinner.Latitude,
                           Longitude = dinner.Longitude,
                           Title = dinner.Title
                           };
        }
        public static Dinner CreateFrom (DinnerInfo dinner)
        {
            return new Dinner()
                       {
                           Address = dinner.Address,
                           ContactPhone = dinner.ContactPhone,
                           Country = dinner.Country,
                           Description = dinner.Description,
                           DinnerID = dinner.DinnerId,
                           EventDate = dinner.EventDate,
                           HostedBy = dinner.HostedBy,
                           Latitude = dinner.Latitude,
                           Longitude = dinner.Longitude,
                           Title = dinner.Title
                       };
        }

        public static IList<DinnerInfo> CreateFrom(PaginatedList<Dinner> pagList)
        {
            List<DinnerInfo> returnList = new List<DinnerInfo>();
            foreach (Dinner dinner in pagList)
            {
                returnList.Add(CreateFrom(dinner));
            }
            return returnList;
        }
    }
}